﻿/// <reference path="RequestHandler.js" />
/// <reference path="../HttpRequest.js" />
/// <reference path="../../utilities/Xpcom.js" />
///--------------------------------------------------------------------
/// <file name="ModeratorControlPanelHandler.js">
///   Adds markup buttons to the moderator control panel page.
/// </file>
///--------------------------------------------------------------------

NAMFox.ns(function() { with (NAMFox) {

this.ModeratorControlPanelHandler = function() {
};

ModeratorControlPanelHandler.prototype = new RequestHandler();
ModeratorControlPanelHandler.prototype.name = "ModeratorControlPanelHandler";

ModeratorControlPanelHandler.prototype.handleRequestCore = function(request, _$) {
    /// <summary>Handles a request.</summary>
    /// <param name="request" type="HttpRequest">The HTTP request which encapsulates the document and route data for this request.</param>
    
    _$("h3").after('<div><input id="namfox-mod-cp-invert-checked" type="button" class="btnup" value="Invert Checked" /></div>');
    
    var checkboxes = _$("input[name=include_forumids\\[\\]]");
    _$("#namfox-mod-cp-invert-checked").click(
        function() {
            checkboxes.each(
                function() {
                    this.checked = !this.checked;
                }
            );
        }
    );
    
    var tables = _$("form:eq(3) table:even tr:eq(2) td:last");
    
    if (tables.length > 0) {
        tables.append('<input name="namfox-mod-queue-invert-checked" type="button" value="Invert Checked" style="background-color: #CCDDEE; border: 1px solid black; font-size: 0.8em;" />');
        
        _$("input[name=namfox-mod-queue-invert-checked]").click(
            function() {
                _$(this.parentNode.parentNode.parentNode).find("input[name=selected_arr\\[\\]]").each(
                    function() {
                        this.checked = !this.checked;
                    }
                );
            }
        );
    }
};

}});